﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _00_Process
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //获取当前正在运行的所有进程
            Process[] processes = Process.GetProcesses();
            //打印所有进程
            foreach (var process in processes)
            {
                Console.WriteLine("进程ID:{0},进程名:{1}", process.Id, process.ProcessName);
            }

            Console.WriteLine("=========================================启动指定程序=========================================");

            //EXE 程序路径
            string exePath = @"C:\Users\Administrator\source\repos2\3_20_WimForm_窗体_控件\01_TCP通讯_服务端\bin\Debug\01_TCP通讯_服务端.exe";
            //启动一个进程
            Process ExeProcess = Process.Start(exePath);

            Console.WriteLine("启动:{0}",exePath);
            Console.WriteLine("等待程序运行10秒后关闭");

            //等待程序运行十秒钟
            System.Threading.Thread.Sleep(10*1000);

            //关闭进程
            ExeProcess.Kill();


            Console.ReadKey();
        }
    }
}
